package com.koron.css2.meterService.mapper;

import com.koron.css2.meterService.bean.MsInfoBean;
import com.koron.css2.meterService.bean.query.MsInfoQueryBean;
import com.koron.css2.meterService.dto.MsInfoDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 水表信息临时表
 */
public interface MsInfoTempMapper {
	
	MsInfoDto selectById(String id);

	String selectUserNoById(String id);
	
	MsInfoDto selectByMeterNo(String meterNo);
	
	List<MsInfoDto> selectList(MsInfoQueryBean bean);
	
	int addMsInfoTemp(MsInfoBean bean);

	/**
	 * 检查表身码是否重复
	 */
	@Select("select count(id) from ms_info where factory_no=#{factoryNo} and meter_no!=#{meterNo}")
	Integer checkFactoryNo(@Param("meterNo")String meterNo, @Param("factoryNo")String factoryNo);

	/**
	 * 检查IMEI是否重复
	 */
	@Select("select count(id) from ms_info where imei = #{imei} and METER_STATUS <> 4 and meter_no != #{meterNo}")
	Integer checkImei(@Param("imei") String imei, @Param("meterNo") String meterNo);

	/**
	 * 检查IMSI是否重复
	 */
	@Select("select count(id) from ms_info where imsi = #{imsi} and METER_STATUS <> 4 and meter_no != #{meterNo}")
	Integer checkImsi(@Param("imsi") String imsi, @Param("meterNo") String meterNo);

	void insert(MsInfoDto msInfoDto);

	void update(MsInfoDto msInfoDto);

    String getIdByMeterNo(@Param("meterNo") String meterNo);
}
